﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Project_ConnectSql.DA;
using System.Data.SqlClient;

namespace Project_ConnectSql
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {

                DataAccess da = new DataAccess();
                dataGridView1.DataSource = da.GetDataLoaihang();
                label1.Text = da.GetCountLoaihang().ToString();
            }
            catch
            {}
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //t
            string tenLoaiHang = textBox1.Text;

            DataAccess da = new DataAccess();
            da.InsertLoaihang(tenLoaiHang);
            //load
            dataGridView1.DataSource = da.GetDataLoaihang();
            label1.Text = da.GetCountLoaihang().ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
             DataAccess da = new DataAccess();
            string ma = textBox2.Text;
            dataGridView1.DataSource = da.GetDataLoaihang(ma);




        }
    } 
}
